app=$1
p=$2

if [ "$app" == "" ]; then 
  echo "./run-node.sh 目录名"
  exit 1;
fi

app=`echo ${app//\//}`

start_sh="/app/node/start.sh"

host_ip=$(docker network inspect bridge | grep Gateway | awk '{print $NF}' | sed 's/"//g')
docker kill $app && docker rm $app

echo "正在启动 $app ..."
docker run   --name $app  --net vm \
  -m 1024m \
  -d \
  -v "$(pwd)/$app":/app \
  -v "$start_sh":/app/exec.sh \
  -w /app  \
  --add-host=nacos:172.17.134.92 \
  --add-host=dc-app:$host_ip \
  --add-host=amy:172.17.134.92 \
  --add-host=dc-qq:43.143.250.229 \
  --add-host=dc-poc:47.104.76.173 \
  --add-host=mysql:172.17.134.92 \
  --add-host=mongo:172.17.134.92 \
  --add-host=redis:172.17.134.92 \
  --add-host=rabbitmq:172.17.134.92 \
  --add-host=es:172.17.134.92 \
  --add-host=minio:172.17.134.92 \
  node:16   /bin/bash  /app/exec.sh $app $p
